<?php
/**
 * NOTICE OF LICENSE
 *
 * This source file is subject to the  Academic Free License (AFL 3.0)
 * that is available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to support@zprofess.com so we can send you a copy immediately.
 *
 * @category   	Prestashop module
 * @package		update database
 * @version 	1.0.0 (April 2012)
 * @author 		kurosaki <kurosaki@zprofess.com>
 * @copyright   Copyright (c) 2011 ZPROFESS. (http://www.zprofess.com)
 * @license    	http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */

//if (!defined('_CAN_LOAD_FILES_'))
//	exit;

require_once(_PS_MODULE_DIR_.'zupdatedb/classes/ZUpdateDBConfig.php');
	
class ZUpdateDB extends ZUpdateDBConfig
{
    const INSTALL_SQL_FILE = 'sql/install.sql';
//    const UNINSTALL_SQL_FILE = 'sql/uninstall.sql';
	/**
     * Sole constructor
     */
    function __construct()
    {    	
    	global $smarty ;
        
        $this->name = 'zupdatedb';	
		$this->version = '1.0.0';
		$this->author = 'Zprofess.com';
		$this->confirmUninstall = $this->l('Are you sure you want to delete your details?');
		$this->displayName = $this->l('Update');
		$this->description = $this->l('Update database and hook headers');
        
        parent::__construct();
    }

    /**
     * Intall module. Creates module tables and adds module configuration
     * to configuration table.
     * @return boolean true if this module installs successfully, false
     * otherwise
     */
	public function install()
	{
		if (!parent::install())
			return false;
		
		/*Register Hook*/
		if (!$this->registerHook('header'))
			return false;
			
		/* install SQL file */		
		if (!$this->_sql(self::INSTALL_SQL_FILE))
			return false;
				
		return true;
	}
	
	/**
     * Uninstall module.
     * Drops module tables from the DB and removes module configuration from
     * the configuration table.
     * @return boolean true if this module uninstalls successfully, false
     * otherwise
     */
	public function uninstall()
	{
		if (!parent::uninstall())
			return false;
			
//		if (!$this->_sql(self::UNINSTALL_SQL_FILE))
//			return false;
		
		return true;
	}	
	public function hookHeader($params)
	{
		global $currency, $smarty, $cookie;
		Tools::addCSS(_THEME_CSS_DIR_.'jquery-ui-1.8.10.custom.css');
		Tools::addJS(_PS_JS_DIR_.'jquery/jquery-ui-1.8.10.custom.min.js');
		Tools::addCSS(_THEME_CSS_DIR_.'style.dialog.login.css');
		
		Tools::addCSS($this->_path.'css/jquery.fancybox-1.3.4.css', 'screen');
		Tools::addJS($this->_path.'js/jquery.fancybox-1.3.4.js');
		Tools::addJS($this->_path.'js/zvalidatepage.js');
		
	}
} 
